package com.codeforces;
import java.util.Scanner;


public class _131A {

	static Scanner scanner = new Scanner(System.in);
	static String s1, s2, s3;

	public static void main(String[] args) {
		s1 = scanner.next();
		s3 = s1.substring(0, 1);
		s2 = s1.substring(1);
		boolean flag = true;
		for (int i=0;i<s2.length();++i) {
			if (s2.charAt(i) >= 'a' && s2.charAt(i) <= 'z') {
				flag = false;
				break;
			}
		}
		if (flag) {
			for (int i=0;i<s1.length();++i) {
				Character ch = s1.charAt(i);
				if (Character.isLowerCase(ch)) {
					System.out.print(Character.toUpperCase(ch));
				}
				else {
					System.out.print(Character.toLowerCase(ch));
				}
			}
			System.out.println();
		}
		else {
			System.out.println(s1);
		}

	}

}
